﻿using CommunityToolkit.Mvvm.Input;
using EFCore.Models;
using NewWms.Apiservice;
using NewWms.Apiservice.Dto;
using NewWms.Views;
using NPOI.SS.Formula.Functions;
using Prism.Regions;
using Prism.Services.Dialogs;
using Reconstruct_Desktop.Apiservice.Dto;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Reconstruct_Desktop.ViewModels
{
    public partial class EntranceRegionViewModel : Prism.Mvvm.BindableBase, INavigationAware
    {


        private Prism.Services.Dialogs.IDialogService Dialog;
        private readonly ShelfManageView shelfManageView;
        private readonly IViewService_Client viewService;
        private readonly IBaseService_Client baseService;
        public EntranceRegionViewModel(Prism.Services.Dialogs.IDialogService dialog) 
        {
            Dialog = dialog;
            viewService = new ViewService_Client();
            baseService = new BaseService_Client();
            InlethouseLineDtos = new List<InlethouseLineDto2>();
            View_Material_WarehouseLine();
        }


        private string inlethousecode;

        public string InlethouseCode
        {
            get { return inlethousecode; }
            set { inlethousecode = value;RaisePropertyChanged(); }
        }

        private List<InlethouseLineDto2> inlethouseLineDtos;

        public List<InlethouseLineDto2> InlethouseLineDtos
        {
            get { return inlethouseLineDtos; }
            set { inlethouseLineDtos = value;RaisePropertyChanged(); }
        }
        private object inlethouseLineDto2;

        public object InlethouseLineDto2
        {
            get { return inlethouseLineDto2; }
            set { inlethouseLineDto2 = value; RaisePropertyChanged(); }
        }


        //功能
        private async void View_Material_WarehouseLine()
        {
            InlethouseLineDtos = await viewService.View_InlethouseLine();
        }

        [RelayCommand]
        private async void ShowDialog(string obj)
        {
            DialogParameters dialogParameters = new DialogParameters();
            if (obj == "UpdateInlethouseLineDialog")
            {
                InlethouseLineDto2 Parameters = (InlethouseLineDto2)InlethouseLineDto2;
                dialogParameters.Add("1", Parameters.Id_InlethouseLine);
            }

            Dialog.ShowDialog(obj, dialogParameters, (r =>
            {
             
            }));
            View_Material_WarehouseLine();
        }







        private string title = "入口管理";
        public string Title
        {
            get { return title; }
            set { title = value; RaisePropertyChanged(); }
        }
        public bool IsNavigationTarget(NavigationContext navigationContext)
        {
            return true;
        }
        public void OnNavigatedFrom(NavigationContext navigationContext)
        {
            
        }
        public void OnNavigatedTo(NavigationContext navigationContext)
        {
            View_Material_WarehouseLine();
        }
    }
}
